using System;
using System.Reflection;

namespace MikeKappel.Com.CS
{
    public static partial class Helper
    {
        /// <summary>
        /// Invoke a member of class in a different control or page
        /// This is used to add OnClick events to UserControls that can be specified at the Page level
        /// The page method must be public to be visible to the UserContol calling this method
        /// <example> MikeKappel.Com.CS.Helper.MethodInvoke(this.Page, "Button1_OnClick", sender, e);</example>
        /// </summary>
        /// <param name="target">target object containing method</param>
        /// <param name="methodToInvoke">name of method to invoke</param>
        /// <param name="paramiters">parameters as needed to invoke method</param>
        public static void MethodInvoke(Object target, String methodToInvoke, params Object[] paramiters)
        {
            MethodInfo methodInfo = target.GetType().GetMethod(methodToInvoke);
            methodInfo.Invoke(target, paramiters);
        }
    }
}